package com.qqtech.qquan.user.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.qqtech.core.common.annotation.VisitAnnt;
import com.qqtech.core.common.enums.RespEnum;
import com.qqtech.core.frame.model.PageOrder;
import com.qqtech.core.frame.model.Result;
import com.qqtech.core.frame.service.BaseService;
import com.qqtech.qquan.user.model.UserBlack;
import com.qqtech.qquan.user.model.UserBlackQuery;
import com.qqtech.qquan.user.model.UserBlackVo;
import com.qqtech.qquan.user.service.UserBlackService;
import com.qqtech.web.context.BaseWebController;

@Controller
@RequestMapping(value = "/user/black")
public class UserBlackController extends BaseWebController<UserBlack, UserBlackQuery> {
	@Resource
	private UserBlackService userBlackService;

	@Override
	protected BaseService<UserBlack> getBaseService() {
		return userBlackService;
	}

	@VisitAnnt(type = RespEnum.LOGIN)
	@RequestMapping(value = "/create")
	@ResponseBody
	public Result create(@RequestBody UserBlackVo userBlackVo) {
		Result ret = new Result();
		Integer curUserId = super.getUserId();
		userBlackVo.setCreatorId(curUserId);
		userBlackService.insert(userBlackVo);
		return ret;
	}

	@VisitAnnt(type = RespEnum.LOGIN)
	@RequestMapping(value = "/delete")
	@ResponseBody
	public Result delete(@RequestBody UserBlackVo userBlackVo) {
		Result ret = new Result();
		Integer curUserId = super.getUserId();
		userBlackVo.setCreatorId(curUserId);
		UserBlackVo userBlackVo2 = userBlackService.getOne(userBlackVo, new PageOrder());
		if (null != userBlackVo2) {
			userBlackService.delete(userBlackVo2);
		}
		return ret;
	}
}
